package net.runsystem.magiccloud;

import net.runsystem.magiccloud.adapter.OnFragmentClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

public class A04_Infor extends Fragment implements OnClickListener {

	public static final int A04_FRAGMENT_CODE = 104;
	OnFragmentClickListener onFragmentClickListener;

	ImageView btSize;
	ImageView btID;
	ImageView btOki;
	ImageView btDate;

	View root;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		// return super.onCreateView(inflater, container, savedInstanceState);
		root = inflater.inflate(R.layout.a04_layout, container, false);

		btID = (ImageView) root.findViewById(R.id.a04_bt_Id);
		btSize = (ImageView) root.findViewById(R.id.a04_bt_Size);
		btOki = (ImageView) root.findViewById(R.id.a04_bt_Oki);
		btDate = (ImageView) root.findViewById(R.id.a04_bt_Date);

		btID.setOnClickListener(this);
		btSize.setOnClickListener(this);
		btOki.setOnClickListener(this);
		btDate.setOnClickListener(this);

		return root;
	}

	@Override
	public void onClick(View arg0) {

		// TODO Auto-generated method stub
		switch (arg0.getId()) {
		case R.id.a04_bt_Id:
			// next page
			if (onFragmentClickListener != null) {
				onFragmentClickListener.onSwitchFragment(
						A04_01_ID.A04_01_FRAGMENT_CODE, null);
			}
			break;
		case R.id.a04_bt_Size:
			// next page
			if (onFragmentClickListener != null) {
				onFragmentClickListener.onSwitchFragment(
						A04_02_Size.A0402_FRAGMENT_CODE, null);
			}
			break;
		case R.id.a04_bt_Oki:

			break;
		case R.id.a04_bt_Date:
			// next page
			if (onFragmentClickListener != null) {
				onFragmentClickListener.onSwitchFragment(
						A04_03_Date.A0403_FRAGMENT_CODE, null);
			}
			break;
		default:
			break;
		}

	}

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
		try {
			onFragmentClickListener = (OnFragmentClickListener) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ " must implement OnFragmentClickListener");
		}
	}

}
